#include <bits/stdc++.h>
using namespace std;
#define int long long

int n, k, lcaa[20][20], dep[20], fa[20];
vector<int> edges[1500006];
vector<pair<int, int>> ljs;

void dfs(int i) {
	for (auto j : edges[i]) {
		if (fa[i] == j) continue;
		dep[j] = dep[i] + 1;
		fa[j] = i;
		dfs(j);
	}
}

int lca(int x, int y){
	if (x == y) return x;
	if (dep[x] < dep[y]) return lca(y, x);
	if (lcaa[x][y] != -1) return lcaa[x][y];
	return lcaa[x][y] = lca(fa[x], y);
}

int geth(int i, int f) {
	if (i == 0) return 0;
	return geth(fa[i], f) + ((f >> (i - 1)) & 1);
}

int len(int i, int j) {
	return dep[i] + dep[j] - 2 * dep[lca(i, j)] + 1;
}

int tlen(int i, int j, int f) {
	return geth(i, f) + geth(j, f) - 2 * geth(fa[lca(i, j)], f) - ((f >> (lca(i, j) - 1)) & 1);
}

signed main() {
	freopen("life.in", "r", stdin); freopen("life.out", "w", stdout);
	cin >> n >> k;
	for (int i = 1; i < n; ++i) {
		int u = i, v = i + 1;
		cin >> u >> v;
		edges[u].push_back(v);
		edges[v].push_back(u);
	}
	if (n <= 18) {
		memset(lcaa, 255, sizeof(lcaa));
		dfs(1);
		int ans = 0;
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= n; ++j) {
				if (len(i, j) == k) ljs.push_back({i, j});
			}
		}
		for (int f = 0; f < (1 << n); ++f) {
			for (auto k : ljs) {
				if (tlen(k.first, k.second, f) != 1) goto end;
			}
			++ans;
			end:;
		}
		if (ans) cout << "YES\n";
		else cout << "NO\n";
		cout << ans << "\n";
	} else {
		cout << "YES\n" << k << "\n";
	}
	return 0;
}
